package com.wx.dao;

import com.wx.pojo.Order;
import org.apache.ibatis.jdbc.SQL;


/**
 * order接口的动态sql类
 */

public class OrderMapper {

        public String findOrder(Order order){
            SQL sql = new SQL();
            sql.SELECT("*");
            sql.FROM("t_order");
            if(order.getId()!=null){
                sql.WHERE("id=#{id}");
            }
            if (order.getMemberId()!=null){
                sql.WHERE("member_id=#{memberId}");
            }
            if(order.getOrderDate()!=null){
                sql.WHERE("orderDate=#{orderDate}");
            }
            if(order.getOrderStatus()!=null){
                sql.WHERE("orderStatus=#{orderStatus}");
            }
            if(order.getSetmealId()!=null){
                sql.WHERE("setmeal_id=#{setmealId}");
            }
            return sql.toString();
        }
    /**
     * 添加方法
     */
    public String addOrder(Order order){
        SQL sql = new SQL();
        sql.INSERT_INTO("t_order");
        if(order.getMemberId()!=null){
            sql.VALUES("member_id","#{memberId}");
        }
        if(order.getOrderDate()!=null){
            sql.VALUES("orderDate","#{orderDate}");
        }
        if(order.getOrderType()!=null){
            sql.VALUES("orderType","#{orderType}");
        }
        if(order.getOrderStatus()!=null){
            sql.VALUES("orderStatus","#{orderStatus}");
        }
        if(order.getSetmealId()!=null){
            sql.VALUES("setmeal_id","#{setmealId}");
        }

        return sql.toString();
    }
}
